<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — —</label><br/>
      <label size="large" label-width="280px">* * * 消防风险模型评估 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — —</label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="300px">
      <el-form-item label="编号" prop="number" required="true">
        <el-input v-model="formData.number" placeholder="请输入编号" :maxlength="20" show-word-limit clearable
                  prefix-icon='el-icon-mobile' :style="{width: '80%'}"></el-input>
      </el-form-item>
      <el-form-item label="建筑内是否涉易燃易爆物经营" prop="jzns">
        <el-select v-model="formData.jzns" placeholder="请选择建筑内是否涉易燃易爆物经营" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in jznsOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="建筑物内是否涉及大功率电器或用电设备" prop="jzwn">
        <el-select v-model="formData.jzwn" placeholder="请选择建筑物内是否涉及大功率电器或用电设备" clearable
                   :style="{width: '80%'}">
          <el-option v-for="(item, index) in jzwnOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="火灾演练周期" prop="hzyl">
        <el-select v-model="formData.hzyl" placeholder="请选择火灾演练周期" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in hzylOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="层数" prop="lcsl">
        <el-input v-model="formData.lcsl" placeholder="请输入层数，如10层，输入10" clearable :style="{width: '80%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="建筑物内从业人员密度ρ（平方米/人）" prop="jzwnc">
        <el-input v-model="formData.jzwnc" placeholder="请输入密度ρ，如ρ为0.5，输入0.5" clearable
                  :style="{width: '80%'}"></el-input>
      </el-form-item>
      <el-form-item label="建筑物所在区域类型" prop="jzws">
        <el-select v-model="formData.jzws" placeholder="请选择建筑物所在区域类型" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in jzwsOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="是否进行智慧消防系统建设" prop="sfjx">
        <el-select v-model="formData.sfjx" placeholder="请选择是否进行智慧消防系统建设" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in sfjxOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="是否进行智慧消防系统建设" prop="field111">
        <el-select v-model="formData.field111" placeholder="请选择是否进行智慧消防系统建设" clearable
                   :style="{width: '80%'}">
          <el-option v-for="(item, index) in field111Options" :key="index" :label="item.label"
                     :value="item.value" :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="当前是否有报警" prop="dqsf">
        <el-select v-model="formData.dqsf" placeholder="请选择当前是否有报警" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in dqsfOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="报警是否处置" prop="bjsf">
        <el-select v-model="formData.bjsf" placeholder="请选择报警是否处置" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in bjsfOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>

    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>编号:{{number}}；得分：{{score}}；风险等级：{{name}}</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handleXF} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {
        centerDialogVisible : false,
        formData: {
          number: '',
          jzns: undefined,
          jzwn: undefined,
          hzyl: undefined,
          lcsl: undefined,
          jzwnc: undefined,
          jzws: undefined,
          sfjx: undefined,
          field111: undefined,
          dqsf: undefined,
          bjsf: undefined,
        },
        rules: {
          number: [{
            required: true,
            message: '请输入编号',
            trigger: 'blur'
          }],
          jzns: [],
          jzwn: [],
          hzyl: [],
          lcsl: [],
          jzwnc: [],
          jzws: [],
          sfjx: [],
          field111: [],
          dqsf: [],
          bjsf: [],
        },
        jznsOptions: [{
          "label": "是",
          "value": 1
        }, {
          "label": "否",
          "value": 2
        }],
        jzwnOptions: [{
          "label": "是",
          "value": 1
        }, {
          "label": "否",
          "value": 2
        }],
        hzylOptions: [{
          "label": "＜1次/年",
          "value": 1
        }, {
          "label": "≥1次/年",
          "value": 2
        }],
        jzwsOptions: [{
          "label": "工业生产建筑",
          "value": 1
        }, {
          "label": "人员密集场所",
          "value": 2
        }, {
          "label": "重要公共建筑",
          "value": 3
        }, {
          "label": "其他特殊建设工程",
          "value": 4
        }, {
          "label": "公众聚集场所",
          "value": 5
        }],
        sfjxOptions: [{
          "label": "否",
          "value": 1
        }, {
          "label": "是",
          "value": 2
        }],
        field111Options: [{
          "label": "否",
          "value": 1
        }, {
          "label": "是",
          "value": 2
        }],
        dqsfOptions: [{
          "label": "否",
          "value": 1
        }, {
          "label": "是",
          "value": 2
        }],
        bjsfOptions: [{
          "label": "正在处置",
          "value": 1
        }, {
          "label": "未处置",
          "value": 2
        }],
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
          handleXF(this.formData).then(response => {
          console.log(response)
          this.number = response.number;
          this.score = response.score,
            this.name = response.name,
            this.centerDialogVisible = true
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
